﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using XinGuanERP.Attributes.system;
using XinGuanERP.Models.Vo.business;
using XinGuanERP.Services.business.IServices;
using XinGuanERP.Utils;

namespace XinGuanERP.Controllers.business;
[DynamicApiController]
public class ConsumerController
{
    private readonly IConsumerService _consumerService;
    public ConsumerController(IConsumerService consumerService)
    {
        _consumerService = consumerService;
    }
    
    [Authorize]
    [ServiceFilter(typeof(MyActionFilterAttribute))]
    public ResultUtil AddConsumer(ConsumerVo consumerVo) =>
        ResultUtil.ok(_consumerService.AddConsumer(consumerVo));
    
    [Authorize]
    [ServiceFilter(typeof(MyActionFilterAttribute))]
    public ResultUtil UpdateConsumer(ConsumerVo consumerVo) =>
        ResultUtil.ok(_consumerService.UpdateConsumer(consumerVo));
    
    [Authorize]
    [ServiceFilter(typeof(MyActionFilterAttribute))]
    public ResultUtil DeleteConsumer(string id) =>
        ResultUtil.ok(_consumerService.DeleteConsumer(id));
    
    [Authorize]
    [ServiceFilter(typeof(MyActionFilterAttribute))]
    [HttpPost]
    public ResultUtil GetConsumerWithPage(ConsumerVo consumerVo) =>
        ResultUtil.ok(_consumerService.GetConsumerWithPage(consumerVo));
    
    [Authorize]
    [ServiceFilter(typeof(MyActionFilterAttribute))]
    public ResultUtil GetConsumerWithList() =>
        ResultUtil.ok(_consumerService.GetConsumerWithList());
}